package com.es.hr.baoxiao;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;

import com.es.business.area.AreaBean;
import com.es.business.area.AreaBiz;
import com.es.business.city.CityBean;
import com.es.business.city.CityBiz;
import com.es.business.citys.CitysBean;
import com.es.business.citys.CitysBiz;
import com.es.business.province.ProvinceBean;
import com.es.business.province.ProvinceBiz;
import com.es.common.CommonBean;
import com.es.common.CommonBiz;
import com.es.hr.baoxiao.BaoxiaoBean;
import com.es.hr.baoxiao.BaoxiaoBiz;
import com.es.hr.emp.EmpInfoBean;
import com.es.main.LoginUserBeen;
import com.es.util.page.PageBean;
import com.opensymphony.webwork.interceptor.ServletRequestAware;
import com.opensymphony.xwork.ActionSupport;

public class SetBaoxiaoPropertyInitAction extends ActionSupport
implements ServletRequestAware{
	 HttpServletRequest request;

	public void setServletRequest(HttpServletRequest paramHttpServletRequest) {
		// TODO Auto-generated method stub
		this.request = paramHttpServletRequest;
	}
	
	public String execute() throws Exception{
		String result = "";
		String message = "";
		CommonBiz commonBiz = new CommonBiz();
		LoginUserBeen userLogin = (LoginUserBeen)request.getSession().getAttribute("loginuser");
		
				ArrayList<CommonBean> commonBeans = new ArrayList<CommonBean>();
				for(int i = 1; i < 32; ++i){
					CommonBean bean = new CommonBean();
					bean.setCommonCode(new Integer(i).toString());
					bean.setCommonValue(new Integer(i).toString());
					commonBeans.add(bean);
				}
				this.request.setAttribute("baxiao_day_list", commonBeans);
				CommonBean baoxiao_day = commonBiz.getCommonByTypeAndCode("baoxiaoproperty", "baoxiaoshenqingriqi");
				CommonBean shenpi_day = commonBiz.getCommonByTypeAndCode("baoxiaoproperty", "baoxiaoshenpiriqi");
				CommonBean chailv_yuzhi = commonBiz.getCommonByTypeAndCode("baoxiaoproperty", "chailvyuzhi");
				
				if(baoxiao_day == null) {
					commonBiz.insertCommon("baoxiaoshenqingriqi", "3", "baoxiaoproperty");
					baoxiao_day = commonBiz.getCommonByTypeAndCode("baoxiaoproperty", "baoxiaoshenqingriqi");
				}
				if(shenpi_day == null) {
					commonBiz.insertCommon("baoxiaoshenpiriqi", "5", "baoxiaoproperty");
					shenpi_day = commonBiz.getCommonByTypeAndCode("baoxiaoproperty", "baoxiaoshenpiriqi");
				}
				if(chailv_yuzhi == null) {
					commonBiz.insertCommon("chailvyuzhi", "700", "baoxiaoproperty");
					chailv_yuzhi = commonBiz.getCommonByTypeAndCode("baoxiaoproperty", "chailvyuzhi");
				}
				
				this.request.setAttribute("baoxiao_day", baoxiao_day);
				this.request.setAttribute("shenpi_day", shenpi_day);
				this.request.setAttribute("chailv_yuzhi", chailv_yuzhi);
				result = "success";
				return result;
	}

}
